home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-08-30 | 3.2 KB | 126 lines | [TEXT/PJMM] |
- program test;
-
- procedure debugBanner (msg: Str255);
- const
- numTicks = 1 * 60; { seconds * ticks/sec }
- kResWIND128 = 128; { WIND resource }
- var
- discard: LongInt;
- banner: WindowPtr;
- oldPort: GrafPtr;
- lineWidth: Integer;
- begin
- GetPort(oldPort);
- banner := GetNewWindow(kResWIND128, nil, Pointer(-1));
- if banner <> nil then
- begin
- ShowWindow(banner); { make the window visible }
- SetPort(banner);
- PenNormal;
- ClipRect(banner^.portRect);
- {$R-}
- lineWidth := TextWidth(QDPtr(@msg[1]), 0, Integer(msg[0]));
- {$R+}
- with banner^.portRect do
- MoveTo(((right - left) - lineWidth) div 2, (bottom - top) div 2);
- {$R-}
- DrawText(QDPtr(@msg[1]), 0, Integer(msg[0]));
- {$R+}
- Delay(numTicks, discard); { wait a while }
- DisposeWindow(banner); { get rid of window }
- end;
- SetPort(oldPort);
- end; { debugBanner }
-
- function hasWaitNextEvent: Boolean;
- { determines if hardware has WNE trap }
- const
- kVersRequested = 2; { as of 6.0.1 }
- kWaitNextEventTrap = $A860; { determines presence of WaitNextEvent }
-
- { system error constants that are missing from THINK interface }
- envBadVers = -5501;
- envVersTooBig = -5502;
-
- type
- pInteger = ^Integer;
-
- var
- result: OSErr;
- theRec: SysEnvRec;
- theRecPtr: ^SysEnvRec;
-
- function GetTrapType (theTrap: Integer): TrapType;
- const
- kOSTrapMask = $0F00; { OS traps start with A0, Tool with A8 or AA. }
- begin
- if BAND(theTrap, $0F00) = 0 then
- GetTrapType := OSTrap
- else
- GetTrapType := ToolTrap;
- end; {GetTrapType}
-
- function TrapExists (theTrap: Integer): Boolean;
- const
- kUnimplementedTrap = $A89F; { unimplemented trap value }
- begin
- TrapExists := GetTrapAddress(kUnimplementedTrap) <> NGetTrapAddress(theTrap, GetTrapType(theTrap));
- end; {TrapExists}
-
- begin
- hasWaitNextEvent := False;
- theRecPtr := @theRec;
- result := SysEnvirons(kVersRequested, theRecPtr^);
- with theRec do
- case result of
- envNotPresent:
- debugBanner('64k ROMS');
- envBadVers:
- debugBanner('negative version number passed SysEnvirons');
- envVersTooBig, noErr:
- begin { good environs call, fill related fields }
- if machineType > envMac then
- hasWaitNextEvent := TrapExists(kWaitNextEventTrap);
- end;
- end; { case }
- end; { hasWaitNextEvent }
-
- function multiFinderTest: Boolean;
- { a little event loop to see if we get mouse-moved events with a tiny region }
- const
- kTries = 10; { number of events to wait for mouse event }
- var
- mouseRgn: RgnHandle;
- count: Integer;
- gotEvent: Boolean;
- theEvent: EventRecord;
- begin
- multiFinderTest := False; { assume false }
- if hasWaitNextEvent then { otherwise always false }
- begin
- debugBanner('has WaitNextEvent');
- gotEvent := False;
- count := 1;
- mouseRgn := NewRgn; { should be empty region (0,0,0,0) }
- while (gotEvent = False) and (count < kTries) do
- begin
- gotEvent := WaitNextEvent(EveryEvent, theEvent, 0, mouseRgn);
- if theEvent.what = app4Evt then
- multiFinderTest := True;
- count := count + 1;
- end;
- DisposeRgn(mouseRgn);
- end;
- end; { multiFinderTest }
-
- var
- multiFinderIsRunning: Boolean;
-
- begin
- multiFinderIsRunning := multiFinderTest;
- if multiFinderIsRunning then
- debugBanner('multiFinder running')
- else
- debugBanner('multiFinder not running');
-
- end. { test }